
#ifndef __BACK_UP_H
#define __BACK_UP_H

#include "main.h" 
#include "MBapp.h"
#define BACK_PARA_NUM  CARD_PARA_LEN

typedef enum
{
	BACK_HEAD    = 0,		    /*0xAA55*/
	BACK_LEN     = 1,		   
  BACK_EN      = 2,		
	BACK_INDEX   = 3,
	BACK_TIME1   = 4,
}BACKUP_REG_DEF;

typedef union
{
	uint32_t dword;
	uint16_t word[2];
	uint8_t  byte[4];
}DWORT_UNION_ST;


#pragma pack(1)
typedef  struct
{
	uint16_t head;                        /*0xAA55*/
	uint16_t len;                         /*保存占空间数*/
	uint16_t saveFlag;                    /*保存标志*/
	uint16_t index;                       /*第几帧*/
	uint8_t saveBuf[BACK_PARA_NUM];      /*保存参数*/
	uint16_t unused[2];                      /*无效，填空*/
}BACKUP_REG_ST; 

#pragma pack()
void backup_init(void);
void backup_savePara(void);
void SetU8Backup(uint8_t addr,uint8_t *data ,uint16_t len);
void SetU16Backup(uint8_t addr,uint16_t *data ,uint16_t len);
void GetU8Backup(uint8_t addr,uint8_t *data ,uint16_t len);
void GetU16Backup(uint8_t addr,uint16_t *data ,uint16_t len);
uint8_t SaveParaBackup(uint8_t *para);
void getParaBackup(void);
void ParaBackupInit(void);
#endif 
